package edu.nctu.csie.jichang.dp.structural;


public class Decorator {
	public static void main(String[] args) {
		Car tBus = new Bus();
		tBus.move();
		DecoratorCar tWingDecorator = new WingDecorator(tBus);
		tWingDecorator.move();
		DecoratorCar tSwingDecorator = new SwingDecorator(tBus);
		tSwingDecorator.move();
	}
}
interface Car{
	void run();
	void move();
}
class Bus implements Car{
	public void run() {System.out.println("Bus can run");}
	public void move() {run();}
}
abstract class DecoratorCar implements Car{
	Car car;
	DecoratorCar(Car car){this.car = car;}
	abstract void runFast();
}
class WingDecorator extends DecoratorCar{
	WingDecorator(Car car) {super(car);	}
	void runFast() {System.out.println("Bus can fly");}
	public void run() {}
	public void move() {
		car.run();
		runFast();
	}
}
class SwingDecorator extends DecoratorCar{
	SwingDecorator(Car car) {super(car);	}
	void runFast() {System.out.println("Bus can Swing");}
	public void run() {}
	public void move() {
		car.run();
		runFast();
	}
}